package com.emcom.gotour.dao.ibatis;

import java.util.List;

import org.springframework.orm.ibatis.SqlMapClientTemplate;

import com.emcom.gotour.dao.TourCategoryDao;
import com.emcom.gotour.po.TourCategory;
import com.ibatis.sqlmap.client.SqlMapClient;

public class IbatisTourCategoryDao implements TourCategoryDao {

	private SqlMapClientTemplate sqlMapClientTemplate;

	public TourCategory query(long id) {
		TourCategory tourCategory = new TourCategory();
		tourCategory.setId(id);
		List<TourCategory> tourCategoryList = query(tourCategory);
		if(tourCategoryList.size() == 1) {
			return tourCategoryList.get(0);
		}
		return null;
	}

	public List<TourCategory> query(TourCategory tourCategory) {
		return sqlMapClientTemplate.queryForList("TourCategory.query", tourCategory);
	}

	public void update(TourCategory tourCategory) {
		sqlMapClientTemplate.update("TourCategory.update", tourCategory);
	}

	public void insert(TourCategory tourCategory) {
		sqlMapClientTemplate.insert("TourCategory.insert", tourCategory);
	}

	public void delete(TourCategory tourCategory) {
		sqlMapClientTemplate.delete("TourCategory.delete", tourCategory);
	}

	public void setSqlMapClient(SqlMapClient sqlMapClient) {
		this.sqlMapClientTemplate = new SqlMapClientTemplate();
		this.sqlMapClientTemplate.setSqlMapClient(sqlMapClient);
	}

}
